package com.gavindon.android.adapters

import android.view.FocusFinder
import android.view.KeyEvent
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.gavindon.android.R
import com.gavindon.android.entity.ComboResp
import com.gavindon.android.network.BASE_URL_IMG
import com.gavindon.android.widget.CornerLabelView
import com.gavindon.android.widget.FocusViewUtils
import java.util.*

/**
 * description: 推荐套餐
 * Created by liNan on  2022-3-1 15:12
 */
class VideoComboAdapter(layoutResId: Int, data: MutableList<ComboResp>?) :
    BaseQuickAdapter<ComboResp, BaseViewHolder>(layoutResId, data) {
    override fun convert(holder: BaseViewHolder, item: ComboResp) {
        FocusViewUtils.scaleView(holder.itemView, 0)
        holder.setText(R.id.ada_tv_combo, item.packageName)
            .setText(R.id.ada_tv_price, "¥${item.presentPrice}")

        val tag = holder.getView<CornerLabelView>(R.id.clv_tag)
        tag.setText1(if (item.validity == 2) "已购买" else "推荐")
        val url = "$BASE_URL_IMG/${item.file?.fileUrl}"
        Glide.with(holder.itemView)
            .load(url)
            .centerCrop()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .into(holder.getView(R.id.ada_combo_iv))
    }

}